<template>
<h2>登录页面</h2>
<table>
    <tr>
        <td>用户名</td>
        <td><input type="text" v-model="info.Uname"/></td>
    </tr>
    <tr>
        <td>密码</td>
        <td><input type="password" v-model="info.Upwd" /></td>
    </tr>
    <tr>
        <td colspan="2" align="center">
            <input type="button" value="登录" @click="ULogin">
        </td>
    </tr>
</table>
</template>
<script setup lang="ts">
import axios from 'axios';
import {ref}from 'vue'
import { useRouter } from 'vue-router';
const router=useRouter()
const info=ref(
    {
        Uname:'',
        Upwd:''
    }
)
const ULogin=()=>{
    axios(
        {
            url:"https://localhost:44382/api/Lx/Ulogin",
            params:info.value,
            method:"get"
        }
    ).then(res=>{
        if(res.data.RM_Id==-1){
            alert(res.data.RM_Name)
        }else if(res.data.RM_Id==-2){
            alert(res.data.RM_Name)
        }else{
            alert(res.data.RM_Name)
            alert(res.data.RM_Data[0].UL_Id)
            SearchUid(res.data.RM_Data[0].UL_Id)
        }
    })
}
const SearchUid=(Uid:string)=>{
    axios.get("https://localhost:44382/api/Lx/SearchU_Id",
        {
            params:{
                Uid:Uid
            }
        }
    ).then(res=>{
        if(res.data>0){
            alert("该用户已经完善信息")
            return
        }else{
            alert("该用户未完善信息")
            router.push({
                path:"/Xq",
                query:{
                    Uid:Uid
                }
            })
        }
    }
    ).catch(err=>{
        console.log(err)
    })
}


</script>